package com.pro01.backend.service;

import com.pro01.backend.dto.UserRatioSummaryDTO;
import com.pro01.backend.mapper.AdminRatioMapper;
import com.pro01.backend.pojo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminRatioService {

    @Autowired
    private AdminRatioMapper adminRatioMapper;

    public PageResult<UserRatioSummaryDTO> getAllUserRatiosPaged(int pageNum, int pageSize) {
        int offset = (pageNum - 1) * pageSize;
        List<UserRatioSummaryDTO> list = adminRatioMapper.getUserRatios(offset, pageSize);
        int total = adminRatioMapper.countAllUsers();
        return new PageResult<>(total, list);
    }

}
